
    /**  
    * @Title: LogStorageOracleConfiguration.java
    * @Package com.efast.cafe.commponent.log.configuration
    * @Description: TODO(用一句话描述该文件做什么)
    * @author Administrator
    * @date 2018年9月4日
    * @version V1.0  
    */
    
package com.efast.cafe.commponent.log.configuration;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import com.alibaba.druid.pool.DruidDataSource;
import com.efast.cafe.commponent.log.constant.LogConstant;
import com.efast.cafe.framework.jdbc.JdbcDao;
import com.efast.cafe.framework.jdbc.JdbcDaoImpl;
import com.efast.cafe.util.ConfigUtil;

/**
    * @ClassName: LogStorageOracleConfiguration
    * @Description: TODO(这里用一句话描述这个类的作用)
    * @author Administrator
    * @date 2018年9月4日
    *
    */
@Configuration
public class LogStorageOracleConfiguration {

	private String storage = ConfigUtil.getValue(LogConstant.K_STORAGE);

	@ConditionalOnProperty(
	        name=LogConstant.K_STORAGE,
	        havingValue="oracle"
	)
	@Bean("oracleLogDruidDataSource")
	@ConfigurationProperties(prefix=LogConstant.K_DATASOURCES_PREFIX)
	public DruidDataSource oracleLogDruidDataSource(){
		DruidDataSource druidDataSource = new DruidDataSource();
		return druidDataSource;
	}
	
	@ConditionalOnProperty(
	        name=LogConstant.K_STORAGE,
	        havingValue="oracle"
	)
	@Bean("oracleLogJdbcTemplate")
	public JdbcTemplate oracleLogJdbcTemplate(){
		JdbcTemplate JdbcTemplate = new JdbcTemplate(oracleLogDruidDataSource());
		return JdbcTemplate;
	}
	
	@Bean("oracleLogJdbcDao")
	public JdbcDao mysqlLogJdbcDao(){
		JdbcDaoImpl jdbcDao = new JdbcDaoImpl();
		if(storage.equals("oracle"))
			jdbcDao.setJdbcTemplate(oracleLogJdbcTemplate());
		return jdbcDao;
	}
}
